
class Shape {
    public void draw() {
        System.out.println("画图");
    }
}
class Rect extends Shape{
    @Override
    public void draw() {
        System.out.println("画矩形");
    }
}
class Ellipse extends Shape{
    @Override
    public void draw() {
        System.out.println("画椭圆");
    }
}
public class demo {
    public static void drawShape() {
        Shape[] shapes = {new Rect(), new Ellipse()};

/*
        Shape[] shapes = new Shape[2];
        shapes[0] = new Rect();
        shapes[1] = new Ellipse();
*/

        for (Shape shape : shapes) {
            shape.draw();
        }
    }

    public static void main(String[] args) {
        drawShape();
    }
    public static void paint(Shape shape) {
        shape.draw();
    }

    public static void main1(String[] args) {
        paint(new Ellipse());
        paint(new Rect());
    }
}
